#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# Test of TypeScript template literal support.

cat <<\EOF > xg-ts-7.ts
const s0: string = _(`A template literal without substitutions`);
const s1: string = _(`A template literal with
embedded
newlines`);
const s2: string = _(`A template literal with ${n} substitutions`);
const s3: string = _(`A template literal with several substitutions: ${a} and ${b} and ${c} and so on`);
const s4: string = `/${looks_like_regex}`;
const s5: string = _('not part of a regex');
const s6: string = `that's a valid string. ` + _('This too');
const s7: string = _(tag`A template literal with a tag`);
const s8: string = `a${`b${`c`+d}`}e`;
const s9: string = _("a normal string");
const s10: string = `abc${foo({}, _('should be extracted'))}xyz`;
const f1 = function (): string {
  return _("first normal string") + `${foo}` + _("second normal string");
};
const s11: string = _("another normal string");
const s12: { property: string } = { property: `A template literal with ${n} substitution` };
const s13: string = _("yet another normal string");
EOF

: ${XGETTEXT=xgettext}
${XGETTEXT} --add-comments --no-location -o xg-ts-7.tmp xg-ts-7.ts 2>xg-ts-7.err
test $? = 0 || { cat xg-ts-7.err; Exit 1; }
func_filter_POT_Creation_Date xg-ts-7.tmp xg-ts-7.pot

cat <<\EOF > xg-ts-7.ok
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

msgid "A template literal without substitutions"
msgstr ""

msgid ""
"A template literal with\n"
"embedded\n"
"newlines"
msgstr ""

msgid "not part of a regex"
msgstr ""

msgid "This too"
msgstr ""

msgid "a normal string"
msgstr ""

msgid "should be extracted"
msgstr ""

msgid "first normal string"
msgstr ""

msgid "second normal string"
msgstr ""

msgid "another normal string"
msgstr ""

msgid "yet another normal string"
msgstr ""
EOF

: ${DIFF=diff}
${DIFF} xg-ts-7.ok xg-ts-7.pot
result=$?

exit $result
